package com.fc.test.util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.List;
import java.util.Map;



import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

public class JsonUtil {
	static String jsonStr = "";
	static Map map = null;

	public static String jsonObjStr(Object obj) {
		Gson gson = new Gson();
		jsonStr = gson.toJson(obj);
		return jsonStr;
	}

	public static String jsonListStr(List obj) {
		Gson gson = new Gson();
		jsonStr = gson.toJson(obj);
		return jsonStr;
	}

	public static String jsonMapStr(Map obj) {
		Gson gson = new Gson();
		jsonStr = gson.toJson(obj);
		return jsonStr;
	}

	public static Map jsonStrMap(String obj) {
		Gson gson = new Gson();
		Type type = new TypeToken<Map>() {
		}.getType(); // 指定集合对象属性
		map = gson.fromJson(obj.toString(), type);
		return map;
	}

	/*public static String dateFormatForGrid(List list, Page page) {
		JSONObject jsonObj = new JSONObject();
		jsonObj.put("Rows", list);
		jsonObj.put("Total", page.getTotal());
		return jsonObjStr(jsonObj);
	}
*/
	public static void main(String[] args) {

	}
}